<template>
	<view class="page page-fill">
		<form @submit="submit">
			<view class="page-block" style="margin-top: 20upx">
				<picker mode="date" @change="dateChange">
					<view class="birth-input">{{birthday}}</view>
				</picker>
			</view>
			
			<button form-type="submit" type="primary" class="submitBtn">提交</button>
		</form>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				birthday: "",
				user: {}
			}
		},
		onLoad () {
			// this.user = this.getGlobalUser();
			// this.birthday = this.user.birthday;
		},
		methods: {
			submit () {
				const me = this;
				uni.request({
					url: this.baseUrl + "/api/edu/user/reset-birthday",
					data: {
						id: this.user.id,
						birthday: this.birthday
					},
					// header: {
					// 	"headerUserId": _this.globalUserInfo.id,
					// 	"headerUserToken": _this.globalUserInfo.userUniqueToken
					// },
					method: "POST",
					success(res) {
						console.log(res);
						if (res.data.data.status === 200) {
							// var userInfo = resData.data
							// uni.setStorageSync("globalUser", userInfo)
							this.user = res.data.data.user;
							me.setGlobalUser(this.user);
							
							uni.navigateBack({
								delta: 1
							})
						} 
					}
				})
			},
			
			dateChange (e) {
				this.birthday = e.detail.value
			}
		}
	}
</script>

<style>
/* 页面铺满屏幕 */
.page-fill {
	width:100%;
	height: 100%;
	position: absolute;
}

.birth-input {
	background-color: white;
	height: 80upx;
	line-height: 80upx;
	padding-left: 20upx;
}

.birthday {
	background-color: white;
	height: 80upx;
	padding-left: 20upx;
	padding-top: 30upx;
}

.submitBtn {
	width: 95%;
	margin-top: 40upx;
}
</style>
